{{extend "layout_admin.html"}}

{{block css}}{{end}}

{{block title}}
<i class="fa fa-user fa-fw"></i>
{{if user_id == 0:}}
新建用户
{{else:}}
编辑用户
{{pass}}
{{end}}

{{block content}}
<input type="hidden" id="hid-user-id" value="{{=user_id}}"/>
<div class="row">
    <div class="col-lg-4">
        <form role="form" class="form-horizontal">
            <fieldset>
                <div class="form-group">
                    <label  class="col-lg-3 control-label">用户名</label>
                    <div class="col-lg-9">
                        {{if user_id == 0:}}
                        <input class="form-control cj-validator" cj-name="用户名" placeholder="用户名" id="txt-username" type="text" cj-required>
                        {{else:}}
                        <input class="form-control" placeholder="用户名" id="txt-username" type="text" value="{{=username}}" disabled>
                        {{pass}}
                    </div>
                </div>
                <div class="form-group">
                    <label  class="col-lg-3 control-label">真实姓名</label>
                    <div class="col-lg-9">
                        <input cj-required cj-range="[1,16]" class="form-control cj-validator" placeholder="真实姓名" id="txt-realname" cj-name="真实姓名" value="{{=realname}}" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label  class="col-lg-3 control-label">密码</label>
                    <div class="col-lg-7">
                        {{if user_id == 0:}}
                        <input class="form-control" id="txt-passwd" type="text" value="chujuexinxi" disabled>
                        <p class="help-block">默认的密码为: chujuexinxi</p>
                        {{else:}}
                        <input class="form-control" id="txt-passwd" placeholder="原始密码不显示" type="text" disabled>
                        {{pass}}
                    </div>
                    <div class="col-lg-2">
                        <button class="btn btn-danger" id="btn-reset-passwd" type="button">重置</button>
                    </div>
                </div>
                <div class="form-group">
                    <label  class="col-lg-3 control-label">电子邮箱</label>
                    <div class="col-lg-9">
                        <input cj-email class="form-control cj-validator" placeholder="电子邮箱" id="txt-email" cj-name="电子邮箱" type="text" value="{{=email}}">
                    </div>
                </div>
                <div class="form-group">
                    <label  class="col-lg-3 control-label">手机号</label>
                    <div class="col-lg-9">
                        <input cj-telephone class="form-control cj-validator" placeholder="手机号" id="txt-telephone" cj-name="手机号" type="text" cj-name="手机号" value={{=telephone}}>
                    </div>
                </div>
                <button class="btn btn-success col-lg-2 col-lg-offset-3" id="btn-save" type="button">保存</button>
                <button class="btn btn-link" id="btn-back" type="button">返回</button>
            </fieldset>
        </form>
    </div>
</div>

{{end}}

{{block js}}
<script type="text/javascript" src="{{=url_for_static('chujue-js/chujue_validate.js')}}"></script>
<script type="text/javascript" src="{{=url_for_static('chujue-js/chujue_ajax.js')}}"></script>
<script src="{{=url_for_static('MD5.js')}}"></script>
<script type="text/javascript" src="{{=url_for_static('views_user_admin/edit.js')}}"></script>

<script type="text/javascript">
    $(function(){
        $("#btn-back").click(function(){
            location.href = "/admin/user-list";
        });

        $("#btn-reset-passwd").click(function(){
            $("#txt-passwd").val("chujuexinxi");
        });

        $("#btn-save").click(save_user);

    });
</script>
{{end}}


